// --------------------------------------------------------------------------------------------
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
// 
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
// 
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
// 
// <remarks>
// Generated by IDLImporter from file nsITelemetry.idl
// 
// You should use these interfaces when you access the COM objects defined in the mentioned
// IDL/IDH file.
// </remarks>
// --------------------------------------------------------------------------------------------
namespace Gecko
{
	using System;
	using System.Runtime.InteropServices;
	using System.Runtime.InteropServices.ComTypes;
	using System.Runtime.CompilerServices;
	
	
	/// <summary>
    ///This Source Code Form is subject to the terms of the Mozilla Public
    /// License, v. 2.0. If a copy of the MPL was not distributed with this
    /// file, You can obtain one at http://mozilla.org/MPL/2.0/. </summary>
	[ComImport()]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("3d3b9075-5549-4244-9c08-b64fefa1dd60")]
	public interface nsIFetchTelemetryDataCallback
	{
		
		/// <summary>
        ///This Source Code Form is subject to the terms of the Mozilla Public
        /// License, v. 2.0. If a copy of the MPL was not distributed with this
        /// file, You can obtain one at http://mozilla.org/MPL/2.0/. </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void Complete();
	}
	
	/// <summary>nsITelemetry </summary>
	[ComImport()]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("273d2dd0-6c63-475a-b864-cb65160a1909")]
	public interface nsITelemetry
	{
		
		/// <summary>
        /// An object containing a snapshot from all of the currently registered histograms.
        /// { name1: {data1}, name2:{data2}...}
        /// where data is consists of the following properties:
        /// min - Minimal bucket size
        /// max - Maximum bucket size
        /// histogram_type - HISTOGRAM_EXPONENTIAL, HISTOGRAM_LINEAR, HISTOGRAM_BOOLEAN
        /// or HISTOGRAM_COUNT
        /// counts - array representing contents of the buckets in the histogram
        /// ranges -  an array with calculated bucket sizes
        /// sum - sum of the bucket contents
        /// static - true for histograms defined in TelemetryHistograms.h, false for ones defined with newHistogram
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetHistogramSnapshotsAttribute(System.IntPtr jsContext);
		
		/// <summary>
        /// Get a snapshot of the internally duplicated subsession histograms.
        /// @param clear Whether to clear out the subsession histograms after snapshotting.
        /// @return An object as histogramSnapshots, except this contains the internally duplicated histograms for subsession telemetry.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal SnapshotSubsessionHistograms([MarshalAs(UnmanagedType.U1)] bool clear, System.IntPtr jsContext);
		
		/// <summary>
        /// The amount of time, in milliseconds, that the last session took
        /// to shutdown.  Reads as 0 to indicate failure.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		uint GetLastShutdownDurationAttribute();
		
		/// <summary>
        /// The number of failed profile lock attempts that have occurred prior to
        /// successfully locking the profile
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		uint GetFailedProfileLockCountAttribute();
		
		/// <summary>
        /// An object containing information about slow SQL statements.
        ///
        /// {
        /// mainThread: { "sqlString1": [<hit count>, <total time>], "sqlString2": [...], ... },
        /// otherThreads: { "sqlString3": [<hit count>, <total time>], "sqlString4": [...], ... }
        /// }
        ///
        /// where:
        /// mainThread: Slow statements that executed on the main thread
        /// otherThreads: Slow statements that executed on a non-main thread
        /// sqlString - String of the offending statement (see note)
        /// hit count - The number of times this statement required longer than the threshold time to execute
        /// total time - The sum of all execution times above the threshold time for this statement
        ///
        /// Note that dynamic SQL strings and SQL strings executed against addon DBs could contain private information.
        /// This property represents such SQL as aggregate database-level stats and the sqlString contains the database
        /// filename instead.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetSlowSQLAttribute(System.IntPtr jsContext);
		
		/// <summary>
        /// See slowSQL above.
        ///
        /// An object containing full strings of every slow SQL statement if toolkit.telemetry.debugSlowSql = true
        /// The returned SQL strings may contain private information and should not be reported to Telemetry.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetDebugSlowSQLAttribute(System.IntPtr jsContext);
		
		/// <summary>
        /// An object containing information about Webrtc related stats. For now it
        /// only contains local and remote ICE candidates avaiable when a Webrtc
        /// PeerConnection gets terminated.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetWebrtcStatsAttribute(System.IntPtr jsContext);
		
		/// <summary>
        /// A number representing the highest number of concurrent threads
        /// reached during this session.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		uint GetMaximalNumberOfConcurrentThreadsAttribute();
		
		/// <summary>
        /// An array of chrome hang reports. Each element is a hang report represented
        /// as an object containing the hang duration, call stack PCs and information
        /// about modules in memory.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetChromeHangsAttribute(System.IntPtr jsContext);
		
		/// <summary>
        /// An array of thread hang stats,
        /// [<thread>, <thread>, ...]
        /// <thread> represents a single thread,
        /// {"name": "<name>",
        /// "activity": <time>,
        /// "hangs": [<hang>, <hang>, ...]}
        /// <time> represents a histogram of time intervals in milliseconds,
        /// with the same format as histogramSnapshots
        /// <hang> represents a particular hang,
        /// {"stack": <stack>, "nativeStack": <stack>, "histogram": <time>}
        /// <stack> represents the hang's stack,
        /// ["<frame_0>", "<frame_1>", ...]
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetThreadHangStatsAttribute(System.IntPtr jsContext);
		
		/// <summary>
        /// An object with two fields: memoryMap and stacks.
        /// * memoryMap is a list of loaded libraries.
        /// * stacks is a list of stacks. Each stack is a list of pairs of the form
        /// [moduleIndex, offset]. The moduleIndex is an index into the memoryMap and
        /// offset is an offset in the library at memoryMap[moduleIndex].
        /// This format is used to make it easier to send the stacks to the
        /// symbolication server.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetLateWritesAttribute(System.IntPtr jsContext);
		
		/// <summary>
        /// Returns an array whose values are the names of histograms defined
        /// in Histograms.json.
        ///
        /// @param dataset - DATASET_RELEASE_CHANNEL_OPTOUT or DATASET_RELEASE_CHANNEL_OPTIN
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void RegisteredHistograms(uint dataset, ref uint count, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] ref string[] histograms);
		
		/// <summary>
        /// Create and return a histogram.  Parameters:
        ///
        /// @param name Unique histogram name
        /// @param expiration Expiration version
        /// @param type - HISTOGRAM_EXPONENTIAL, HISTOGRAM_LINEAR or HISTOGRAM_BOOLEAN
        /// @param min - Minimal bucket size
        /// @param max - Maximum bucket size
        /// @param bucket_count - number of buckets in the histogram.
        /// The returned object has the following functions:
        /// add(int) - Adds an int value to the appropriate bucket
        /// snapshot() - Returns a snapshot of the histogram with the same data fields as in histogramSnapshots()
        /// clear() - Zeros out the histogram's buckets and sum
        /// dataset() - identifies what dataset this is in: DATASET_RELEASE_CHANNEL_OPTOUT or ...OPTIN
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal NewHistogram([MarshalAs(UnmanagedType.LPStruct)] nsACStringBase name, [MarshalAs(UnmanagedType.LPStruct)] nsACStringBase expiration, uint histogram_type, uint min, uint max, uint bucket_count, System.IntPtr jsContext, int argc);
		
		/// <summary>
        /// Create a histogram using the current state of an existing histogram.  The
        /// existing histogram must be registered in TelemetryHistograms.h.
        ///
        /// @param name Unique histogram name
        /// @param existing_name Existing histogram name
        /// The returned object has the same functions as a histogram returned from newHistogram.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal HistogramFrom([MarshalAs(UnmanagedType.LPStruct)] nsACStringBase name, [MarshalAs(UnmanagedType.LPStruct)] nsACStringBase existing_name, System.IntPtr jsContext);
		
		/// <summary>
        /// Same as newHistogram above, but for histograms registered in TelemetryHistograms.h.
        ///
        /// @param id - unique identifier from TelemetryHistograms.h
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetHistogramById([MarshalAs(UnmanagedType.LPStruct)] nsACStringBase id, System.IntPtr jsContext);
		
		/// <summary>
        /// An object containing a snapshot from all of the currently registered keyed histograms.
        /// { name1: {histogramData1}, name2:{histogramData2}...}
        /// where the histogramData is as described in histogramSnapshots.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetKeyedHistogramSnapshotsAttribute(System.IntPtr jsContext);
		
		/// <summary>
        /// Create and return a keyed histogram.  Parameters:
        ///
        /// @param name Unique histogram name
        /// @param expiration Expiration version
        /// @param type - HISTOGRAM_EXPONENTIAL, HISTOGRAM_LINEAR, HISTOGRAM_BOOLEAN, HISTOGRAM_FLAG or HISTOGRAM_COUNT
        /// @param min - Minimal bucket size
        /// @param max - Maximum bucket size
        /// @param bucket_count - number of buckets in the histogram.
        /// The returned object has the following functions:
        /// add(string key, [optional] int) - Add an int value to the histogram for that key. If no histogram for that key exists yet, it is created.
        /// snapshot([optional] string key) - If key is provided, returns a snapshot for the histogram with that key or null. If key is not provided, returns the snapshots of all the registered keys in the form {key1: snapshot1, key2: snapshot2, ...}.
        /// keys() - Returns an array with the string keys of the currently registered histograms
        /// clear() - Clears the registered histograms from this.
        /// dataset() - identifies what dataset this is in: DATASET_RELEASE_CHANNEL_OPTOUT or ...OPTIN
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal NewKeyedHistogram([MarshalAs(UnmanagedType.LPStruct)] nsACStringBase name, [MarshalAs(UnmanagedType.LPStruct)] nsACStringBase expiration, uint histogram_type, uint min, uint max, uint bucket_count, System.IntPtr jsContext, int argc);
		
		/// <summary>
        /// Returns an array whose values are the names of histograms defined
        /// in Histograms.json.
        ///
        /// @param dataset - DATASET_RELEASE_CHANNEL_OPTOUT or ...OPTIN
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void RegisteredKeyedHistograms(uint dataset, ref uint count, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] ref string[] histograms);
		
		/// <summary>
        /// Same as newKeyedHistogram above, but for histograms registered in TelemetryHistograms.h.
        ///
        /// @param id - unique identifier from TelemetryHistograms.h
        /// The returned object has the same functions as a histogram returned from newKeyedHistogram.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetKeyedHistogramById([MarshalAs(UnmanagedType.LPStruct)] nsACStringBase id, System.IntPtr jsContext);
		
		/// <summary>
        /// A flag indicating if Telemetry can record base data (FHR data). This is true if the
        /// FHR data reporting service or self-support are enabled.
        ///
        /// In the unlikely event that adding a new base probe is needed, please check the data
        /// collection wiki at https://wiki.mozilla.org/Firefox/Data_Collection and talk to the
        /// Telemetry team.
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool GetCanRecordBaseAttribute();
		
		/// <summary>
        /// A flag indicating if Telemetry can record base data (FHR data). This is true if the
        /// FHR data reporting service or self-support are enabled.
        ///
        /// In the unlikely event that adding a new base probe is needed, please check the data
        /// collection wiki at https://wiki.mozilla.org/Firefox/Data_Collection and talk to the
        /// Telemetry team.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void SetCanRecordBaseAttribute([MarshalAs(UnmanagedType.U1)] bool aCanRecordBase);
		
		/// <summary>
        /// A flag indicating if Telemetry is allowed to record extended data. Returns false if
        /// the user hasn't opted into "extended Telemetry" on the Release channel, when the
        /// user has explicitly opted out of Telemetry on Nightly/Aurora/Beta or if manually
        /// set to false during tests.
        ///
        /// Set this to false in tests to disable gathering of extended telemetry statistics.
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool GetCanRecordExtendedAttribute();
		
		/// <summary>
        /// A flag indicating if Telemetry is allowed to record extended data. Returns false if
        /// the user hasn't opted into "extended Telemetry" on the Release channel, when the
        /// user has explicitly opted out of Telemetry on Nightly/Aurora/Beta or if manually
        /// set to false during tests.
        ///
        /// Set this to false in tests to disable gathering of extended telemetry statistics.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void SetCanRecordExtendedAttribute([MarshalAs(UnmanagedType.U1)] bool aCanRecordExtended);
		
		/// <summary>
        /// A flag indicating whether Telemetry can submit official results (for base or extended
        /// data). This is true on official builds with built in support for Mozilla Telemetry
        /// reporting.
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool GetIsOfficialTelemetryAttribute();
		
		/// <summary>
        /// Register a histogram for an addon.  Throws an error if the
        /// histogram name has been registered previously.
        ///
        /// @param addon_id - Unique ID of the addon
        /// @param name - Unique histogram name
        /// @param histogram_type - HISTOGRAM_EXPONENTIAL, HISTOGRAM_LINEAR,
        /// HISTOGRAM_BOOLEAN or HISTOGRAM_COUNT
        /// @param min - Minimal bucket size
        /// @param max - Maximum bucket size
        /// @param bucket_count - number of buckets in the histogram
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void RegisterAddonHistogram([MarshalAs(UnmanagedType.LPStruct)] nsACStringBase addon_id, [MarshalAs(UnmanagedType.LPStruct)] nsACStringBase name, uint histogram_type, uint min, uint max, uint bucket_count, int argc);
		
		/// <summary>
        /// Return a histogram previously registered via
        /// registerAddonHistogram.  Throws an error if the id/name combo has
        /// not been registered via registerAddonHistogram.
        ///
        /// @param addon_id - Unique ID of the addon
        /// @param name - Registered histogram name
        ///
        /// The returned object has the same functions as a histogram returned
        /// from newHistogram.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetAddonHistogram([MarshalAs(UnmanagedType.LPStruct)] nsACStringBase addon_id, [MarshalAs(UnmanagedType.LPStruct)] nsACStringBase name, System.IntPtr jsContext);
		
		/// <summary>
        /// Delete all histograms associated with the given addon id.
        ///
        /// @param addon_id - Unique ID of the addon
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void UnregisterAddonHistograms([MarshalAs(UnmanagedType.LPStruct)] nsACStringBase addon_id);
		
		/// <summary>
        /// Enable/disable recording for this histogram at runtime.
        /// Recording is enabled by default, unless listed at kRecordingInitiallyDisabledIDs[].
        /// Name must be a valid Histogram identifier, otherwise an assertion will be triggered.
        ///
        /// @param id - unique identifier from histograms.json
        /// @param enabled - whether or not to enable recording from now on.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void SetHistogramRecordingEnabled([MarshalAs(UnmanagedType.LPStruct)] nsACStringBase id, [MarshalAs(UnmanagedType.U1)] bool enabled);
		
		/// <summary>
        /// An object containing a snapshot from all of the currently
        /// registered addon histograms.
        /// { addon-id1 : data1, ... }
        ///
        /// where data is an object whose properties are the names of the
        /// addon's histograms and whose corresponding values are as in
        /// histogramSnapshots.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetAddonHistogramSnapshotsAttribute(System.IntPtr jsContext);
		
		/// <summary>
        /// Read data from the previous run. After the callback is called, the last
        /// shutdown time is available in lastShutdownDuration and any late
        /// writes in lateWrites.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void AsyncFetchTelemetryData([MarshalAs(UnmanagedType.Interface)] nsIFetchTelemetryDataCallback aCallback);
		
		/// <summary>
        /// Get statistics of file IO reports, null, if not recorded.
        ///
        /// The statistics are returned as an object whose propoerties are the names
        /// of the files that have been accessed and whose corresponding values are
        /// arrays of size three, representing startup, normal, and shutdown stages.
        /// Each stage's entry is either null or an array with the layout
        /// [total_time, #creates, #reads, #writes, #fsyncs, #stats]
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetFileIOReportsAttribute(System.IntPtr jsContext);
		
		/// <summary>
        /// Return the number of seconds since process start using monotonic
        /// timestamps (unaffected by system clock changes).
        /// @throws NS_ERROR_NOT_AVAILABLE if TimeStamp doesn't have the data.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		double MsSinceProcessStart();
	}
	
	/// <summary>nsITelemetryConsts </summary>
	public class nsITelemetryConsts
	{
		
		// <summary>
        // Histogram types:
        // HISTOGRAM_EXPONENTIAL - buckets increase exponentially
        // HISTOGRAM_LINEAR - buckets increase linearly
        // HISTOGRAM_BOOLEAN - For storing 0/1 values
        // HISTOGRAM_FLAG - For storing a single value; its count is always == 1.
        // HISTOGRAM_COUNT - For storing counter values without bucketing.
        // </summary>
		public const ulong HISTOGRAM_EXPONENTIAL = 0;
		
		// 
		public const ulong HISTOGRAM_LINEAR = 1;
		
		// 
		public const ulong HISTOGRAM_BOOLEAN = 2;
		
		// 
		public const ulong HISTOGRAM_FLAG = 3;
		
		// 
		public const ulong HISTOGRAM_COUNT = 4;
		
		// <summary>
        // Dataset types:
        // DATASET_RELEASE_CHANNEL_OPTOUT - the basic dataset that is on-by-default on all channels
        // DATASET_RELEASE_CHANNEL_OPTIN - the extended dataset that is opt-in on release,
        // opt-out on pre-release channels.
        // </summary>
		public const ulong DATASET_RELEASE_CHANNEL_OPTOUT = 0;
		
		// 
		public const ulong DATASET_RELEASE_CHANNEL_OPTIN = 1;
	}
}
